//
//  ViewController.m
//  OC_Test_01
//
//  Created by IOS3 on 2018/10/19.
//  Copyright © 2018年 IOS3. All rights reserved.
//

#import "ViewController.h"
#import "NSObject+GetValue.h"

@interface ViewController () <UITableViewDelegate, UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSArray *listDatas;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"homeSubTitle"];
    
    [self test];
}

- (void)test {

    NSDictionary *dict = @{
                           @"arr" : @[@1, @2, @3],
                           @"arr2" : @[@{}],
                           };
    NSObject *a = dict.fromIndex(1);
    id b = dict.fromKey(@"arr").fromIndex(4);
    id e = dict.fromKey(@"arr").fromIndex(1);
    dict = [[NSNull alloc] init];
    id c = dict.fromKey(@"c");
    int f = [e intValue];
    
    NSString *str = nil;
    
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.listDatas.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"homeSubTitle" forIndexPath:indexPath];
    NSDictionary *data = self.listDatas[indexPath.row];
    cell.textLabel.text = data[@"title"];
    cell.detailTextLabel.text = data[@"class"];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *classStr = self.listDatas[indexPath.row][@"class"];
    Class clazz = NSClassFromString(classStr);
    UIViewController *controller = (UIViewController *)[[clazz alloc] init];
    [self.navigationController pushViewController:controller animated:YES];
}

- (NSArray *)listDatas {
    if (!_listDatas) {
        _listDatas = @[
                       @{@"title" : @"测试屏幕的适配", @"class" : @"TestScreenController"},
                       @{@"title" : @"测试屏幕的适配", @"class" : @"BaseTableViewController"},
                       ];
    }
    return _listDatas;
}

@end
